feat(monitor): port Monitor V2 commands from Go CLI#18
Draft
beengud wants to merge 1 commit into
Draft
Conversation
Add `observe monitor` with list, get, preview-query, preview, and alarms subcommands backed by the published monitorV2 GraphQL operations. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6
Ported surface —
observe monitormonitor list [<name-substring>]searchMonitorV2monitor get <id>monitorV2monitor preview-query <file.json>evaluateMonitorV2Sourcemonitor preview [--workspace <id>] [--since <dur>] <file.json>previewMonitorV2monitor alarms [--workspace] [--monitor-id] [--since] [--level]searchMonitorV2AlarmsInput JSON is
MonitorV2Input(min:name,ruleKind,definition). All commands support--format json|csv.Field-name corrections vs the Go CLI (the Go queries were written against an older schema)
The published SDL (
terraform-provider-observe) differs substantially from the Go fork's hand-written queries. Corrections made to match the authoritative schema:searchMonitorV2/searchMonitorV2Alarmsreturnresults, notmonitors/alarms.previewMonitorV2requires aparams: QueryParams!arg (Go omitted it) and returnsMonitorV2Preview { alarms, stabilityBookmarkTime, alertSchema }— there is nowouldFire/samples. "Would fire" is derived asalarms.length > 0; groupings come from each alarm'scontext/capturedValues.searchMonitorV2Alarmsargs aremonitorIds: [ObjectId!],minTime/maxTime(Go usedmonitorId,startTime/endTime).MonitorV2Alarmhas nomonitorId/status—monitorIdcomes frommonitor { id }andstatusis derived fromisActive(Active/Ended).evaluateMonitorV2SourcereturnsMonitorV2SourceEvaluation { query: MultiStageQuery! }— there is nopipeline/resultSchema; the OPAL is inquery.stages[].pipeline.searchMonitorV2/previewMonitorV2/searchMonitorV2AlarmstakeworkspaceId: ObjectId(nullable) → exposed via optional--workspace(the new CLIConfighas no workspace).MonitorV2AlarmLevelenum values are capitalized (Critical/Error/Warning/Informational);--levelaccepts lowercase and normalizes.monitor getrenders a human summary by default (noyamldependency in the repo);--format jsonemits the full monitor incl. definition.Verification
graphql-code-generatoragainst the published SDL ends✔ Generate— all five operations validate against the schema with zero document errors.tsc --noEmitis clean forsrc/commands/monitorandsrc/gql/monitor(only unrelatedbun:test/other-resource noise outside the feature).bun test src/commands/monitor/→ 18 pass / 0 fail across 5 files.🤖 Generated with Claude Code